{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "ein.tags": "worksheet-0",
    "slideshow": {
     "slide_type": "-"
    }
   },
   "source": [
    "python 类机制\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "autoscroll": false,
    "collapsed": false,
    "ein.hycell": false,
    "ein.tags": "worksheet-0",
    "slideshow": {
     "slide_type": "-"
    }
   },
   "outputs": [],
   "source": [
    "\n",
    "class A(object):\n",
    "    name = \"A\"\n",
    "    def __init__(self):\n",
    "        print(\"A Class init: \", self.name)\n",
    "\n",
    "    def print_name(self):\n",
    "        print(\"object name: \", self.name)\n",
    "\n",
    "class B(object):\n",
    "    name = \"B\"\n",
    "    def __init__(self):\n",
    "        print(\"B Class init: \", self.name)\n",
    "\n",
    "\n",
    "class C(A, B):\n",
    "    name = \"C\"\n",
    "    def __init__(self):\n",
    "        print(\"C Class init:\", self.name)\n",
    "        super().__init__()\n",
    "\n",
    "    def print_name(self):\n",
    "        print(\"C object name: \", self.name)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "autoscroll": false,
    "collapsed": false,
    "ein.hycell": false,
    "ein.tags": "worksheet-0",
    "slideshow": {
     "slide_type": "-"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C Class init: C\n",
      "A Class init:  C\n",
      "C object name:  C\n"
     ]
    }
   ],
   "source": [
    "\n",
    "c = C()\n",
    "\n",
    "c.print_name()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "name": "python3"
  },
  "name": "pythonlei-ji-zhi.ipynb",
  "nikola": {
   "category": "",
   "date": "2019-01-14 13:46:23 UTC+08:00",
   "description": "",
   "link": "",
   "slug": "pythonlei-ji-zhi",
   "tags": "",
   "title": "python类机制",
   "type": "text"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
